import tensorflow as tf
def gen_tf_example(data: dict):
  features_map = {}
  for key, val in data.items():
    if type(val) == list:
      dtype = type(val[0])
    else:
      dtype = type(val)
      val = [val]
#     print(dtype)
    if dtype == int or dtype == tf.int64 or dtype == tf.int32:
      features_map[key] = tf.train.Feature(
          int64_list=tf.train.Int64List(value=val))
    elif dtype == float or dtype == tf.float32 or dtype == tf.float64:
      features_map[key] = tf.train.Feature(
          float_list=tf.train.FloatList(value=val))
    else:
#       print(dtype)
      features_map[key] = tf.train.Feature(
          bytes_list=tf.train.BytesList(value=[v.encode('utf-8') for v in val]))
  example = tf.train.Example(features=tf.train.Features(feature=features_map))
  return example
